package com.candicom.race.cars;

class BMW extends AbstractCar {

    private final double topSpeed = 50;
    private final double acceleration = 2;
    private final int turningSensitivity = 2;

    BMW() throws Exception {
        super(CarModel.BMW, "bmw.png");
    }

    @Override
    public void speedUp() {
        if (speed + acceleration > topSpeed) {
            speed = topSpeed;
        } else {
            speed += acceleration;
        }
    }

    @Override
    public void slowDown() {
        if (speed - (acceleration / 2) < 0) {
            speed = 0;
        } else {
            speed -= (acceleration / 2);
        }
    }

    @Override
    public void turnRight() {
        angle = (angle + turningSensitivity) % 360;
    }

    @Override
    public void turnLeft() {
        angle = (360 + angle - turningSensitivity) % 360;
    }
}
